package com.uzhie.jt808.msg.entity.JT_200;

import com.uzhie.jt808.msg.entity.IPositionAdditionalItem;
import org.apache.log4j.Logger;

/**
 * 位置信息工厂
 */
public final class PositionAdditionalFactory {

    private static Logger logger = Logger.getLogger(PositionAdditionalFactory.class);

    public static IPositionAdditionalItem CreatePositionalFactory(int additionalId, byte length, byte[] bytes) {
        IPositionAdditionalItem additional = null;
        switch (additionalId) {
            //里程
            case 0x01:
                additional = new PostitionAdditional_Mileage();
                additional.ReadFromBytes(bytes);
                break;
            //油量
            case 0x02:
                additional = new PostitionAdditional_Oil();
                additional.ReadFromBytes(bytes);
                break;
            //速度
            case 0x03:
                additional = new PostitionAdditional_RecorderSpeed();
                additional.ReadFromBytes(bytes);
                break;
            //需要人工判定的报警事件
            case 0x04:
                additional = new PostitionAdditional_AlarmEventId();
                additional.ReadFromBytes(bytes);
                break;
            // 超速报警
            case 0x11:
                additional = new PostitionAdditional_OverSpeedAlarmAdditional();
                additional.ReadFromBytes(bytes);
                break;
            //进出区域/路线报警
            case 0x12:
                additional = new PostitionAdditional_InOutAreaAlarmAdditional();
                additional.ReadFromBytes(bytes);
                break;
            //路段行驶时间不足/过长
            case 0x13:
                additional = new PostitionAdditional_RouteDriveTimeAlarmAdditional();
                additional.ReadFromBytes(bytes);
                break;
            //无线通信网络信号强度
            case 0x30:
                additional = new PostitionAdditional_IgnalIntensity();
                additional.ReadFromBytes(bytes);
                break;
            //GNSS 定位卫星数
            case 0x31:
                additional = new PostitionAdditional_GpsIntensity();
                additional.ReadFromBytes(bytes);
                break;
            // ODA 扩展数据
            case 0xE0:
                PostitionAdditional_FollowedBytesLength folloedBytesLength = new PostitionAdditional_FollowedBytesLength();
                folloedBytesLength.setAdditionalLength(length);
                folloedBytesLength.ReadFromBytes(bytes);
                additional = folloedBytesLength;
                break;
            case 0xE1:
                additional = new PostitionAdditional_Voltage();
                additional.ReadFromBytes(bytes);
                break;
            case 0xE2:
                additional = new OBDExtensions();
                additional.ReadFromBytes(bytes);
                break;
            //视频相关报警
            case 0x14:
                additional = new Media_Warn();
                additional.ReadFromBytes(bytes);
                break;
            //视频信号丢失报警
            case 0x15:
                additional = new Media_Dropout();
                additional.ReadFromBytes(bytes);
                break;
            //视频信号遮挡报警
            case 0x16:
                additional = new Media_Occlusion();
                additional.ReadFromBytes(bytes);
                break;
            //存储器异常报警
            case 0x17:
                additional = new Media_Storager();
                additional.ReadFromBytes(bytes);
                break;
            //异常驾驶行为
            case 0x18:
                additional = new Media_Fatigue();
                additional.ReadFromBytes(bytes);
                break;
            // 苏标 高级驾驶辅助报警
            case 0X64:
                logger.trace("苏标 高级驾驶辅助报警");
                additional = new JS_DrivingAssistanceSystemWarn();
                additional.ReadFromBytes(bytes);
                break;
            // 苏标 驾驶员状态监测系统报警
            case 0X65:
                logger.trace("苏标 驾驶员状态监测系统报警");
                additional = new JS_DriverStatusMonitorSystemWarn();
                additional.ReadFromBytes(bytes);
                break;
            // 苏标 胎压监测系统报警
            case 0X66:
                logger.trace("苏标 胎压监测系统报警");
                additional = new JS_TirePressureMonitorSystemWarn();
                additional.ReadFromBytes(bytes);
                break;
            // 苏标 盲区监测系统报警
            case 0X67:
                logger.trace("苏标 盲区监测系统报警");
                additional = new JS_BlindAreaMonitorSystemWarn();
                additional.ReadFromBytes(bytes);
                break;
            default:
                break;
        }
        return additional;
    }
}